﻿layui.use(['form', 'layedit', 'laydate', 'element'], function () {
    var form = layui.form
        , layer = layui.layer
        , layedit = layui.layedit
        , laydate = layui.laydate;

    //自定义验证规则
    form.verify({
        yz: function (value) {
            if (value.length < 1) {
                return '至少输入一个字符';
            }
        }
    });

    //监听提交
    form.on('submit(submit)', function (data) {
        var jsonStr = JSON.stringify(data.field);
        $.ajax({
            url: '/Leave/AddLeaveMsg',
            type: 'post',
            data: {
                Str: jsonStr, FlowContent: $("#FlowContent").val(), FormContent: $("#FormContent").val()
            },
            success: function (d) {
                if (d.code === 0) {
                    parent.alertMsy();
                }
                else {
                    layer.msg("失败", {
                        time: 2000 //20s后自动关闭
                        , icon: 5
                    });
                }
            }
        });
        var index = parent.layer.getFrameIndex(window.name); // 得到索引
        parent.layer.close(index);
    });


});
